package com.chinamobile.maps.util;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;

/**
 * @author FrankWong
 *
 */
public class Struts2Util {

	
	
	/**
	 * request
	 * @return
	 */
	public static HttpServletRequest getRequest(){
		ActionContext ctx = ActionContext.getContext(); 
		return (HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST);        

	}
	/**
	 * response
	 * @return
	 */
	public static HttpServletResponse getResponse(){
		ActionContext ctx = ActionContext.getContext(); 
		return  (HttpServletResponse)ctx.get(ServletActionContext.HTTP_RESPONSE);  
	}
	/**
	 * Session
	 * @return
	 */
	public static HttpSession getSession(){
		ActionContext ctx = ActionContext.getContext(); 
//		return (HttpSession)ctx.get(ServletActionContext.SESSION);
		return ((HttpServletRequest)ctx.get(ServletActionContext.HTTP_REQUEST)).getSession();
	}
	/**
	 * sessionMap
	 * @return
	 */
	public static Map getSessionMap(){
		ActionContext ctx = ActionContext.getContext(); 
		return ctx.getSession();
	}
}
